#ifndef CHARACTERCONTROLLER_H
#define CHARACTERCONTROLLER_H

#include "Character.h"
#include "CharacterBall.h"
#include "Collision.h"

#define TEST_GROUND 0.1

class CharacterController
{
    Character* currentCharacter;
public:
    CharacterController();
    void setCharacter(Character* c);
    Character* getCharacter();
    void invokeCharRender();
    void invokeCharMoveForward();
    void invokeCharMoveBackward();
    void invokeCharMoveLeft();
    void invokeCharMoveRight();
    void invokeCharMoveJump();
};

inline
void CharacterController::setCharacter(Character* c){
    currentCharacter = c;
}

inline
Character* CharacterController::getCharacter(){
    return currentCharacter;
}

inline
void CharacterController::invokeCharRender(){
    if(Collision::hasCollidedDownAtOffset(*currentCharacter,vector3<float>(0,-TEST_GROUND,0)))
       currentCharacter->setState(WALKING);

    currentCharacter->render();
}

inline
void CharacterController::invokeCharMoveForward(){
    currentCharacter->goForward();
}

inline
void CharacterController::invokeCharMoveBackward(){
    currentCharacter->goBackward();
}

inline
void CharacterController::invokeCharMoveLeft(){
    currentCharacter->goLeft();
}

inline
void CharacterController::invokeCharMoveRight(){
    currentCharacter->goRight();
}

inline
void CharacterController::invokeCharMoveJump(){
    if(currentCharacter->getState()==WALKING){
    currentCharacter->Jump();
    currentCharacter->setState(JUMPING);
    }
}


#endif // CHARACTERCONTROLLER_H
